/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session01;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author SinhNX
 */
public class JDBC_ODBC {
    public static void main(String[] args) {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            
            Connection cn = DriverManager.getConnection("jdbc:odbc:APJ2");
            
            Statement stm = cn.createStatement();
            
            ResultSet rs = stm.executeQuery("SELECT * FROM Subjects");
            
            while(rs.next()){
                System.out.printf("%-10s | %-40s | %4d | %4d\n", rs.getString("SubjectID"), rs.getString("SubjectName"), rs.getInt(3), rs.getInt(4));
            }
        } catch (SQLException ex) {
            Logger.getLogger(JDBC_ODBC.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(JDBC_ODBC.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
